class Depend {
  constructor() {
    this,reactiveFns = []
  }

  addDepend(reactiveFn) {
    this.reactiveFns.push(reactiveFn)
  }

  notify() {
    this.reactiveFns.forEach(fn => {
      fn()
    })
  }

}

// 封装一个响应式函数
const depend = new Depend()
function watchFn(fn){
  depend.addDepend(fn)
}
// 对象的响应式
const obj = {
  name: "yz",
  age: 18
}

watchFn(function() {
  const newName = obj.name
  console.log("haha");
  console.log(obj.name);
})
watchFn(function() {
  console.log(obj.name, "demo");
})


obj.name = "jay"

reactiveFnArr.forEach(fn => {
  fn()
})

